<?php
namespace yan\hkecship\box;
/**
 * 定義 x長 y寬 z高 width為最小的 hegiht 中間 depth為最大
 * */
class Item{
	public $width; //x
	public $height; //y
	public $depth; //z
	public $weight;
	public $volume = 0;
	public $is_over = 0;
	public $is_add = 0;
	public $position='x.y.z'; //擺放向量 對應 大箱子的 長寬高
	public function __construct($width, $height, $depth, $weight){
		$width = empty($width) ? 0 : $width;
		$width = empty($height) ? 0 : $height;
		$depth = empty($depth) ? 0 : $depth;
		$weight = empty($weight) ? 0 : $weight;
		if($width <= $height){
			if($height <= $depth){
				$this->width = $width;
				$this->height = $height;
				$this->depth = $depth;
			}else{
				$this->depth = $height;
				if($width <= $depth){
					$this->width = $width;
					$this->height = $depth;
				}else{
					$this->width = $depth;
					$this->height = $width;
				}
			}
		}else{ //x > y
			if($width <= $depth){
				$this->width = $height;
				$this->height = $width;
				$this->depth = $depth;
			}else{
				$this->depth = $width;
				if($height <= $depth){
					$this->width = $height;
					$this->height = $depth;
				}else{
					$this->width = $depth;
					$this->height = $height;
				}
			}
		}
		$this->width = round($this->width, 2);
		$this->height = round($this->height, 2);
		$this->depth = round($this->depth, 2);
		$this->weight = $weight;
		$this->volume = $this->width * $this->height * $this->depth;
	}
	public function getMax(){
		return max($this->weight, $this->height, $this->depth);
	}
}